//
//  MCVIPCenterHeaderView.m
//  TLYL
//
//  Created by MC on 2017/11/22.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCVIPCenterHeaderView.h"
#import "NSString+Helper.h"
#define H_MCVIPCenter (180+75)*G_SCREENWIDTH/375.0
#define WIDTH_BTN  45
#define NAVTOP 64
@interface MCVIPCenterHeaderView()

@property (nonatomic ,strong)UIImageView * backImgV;
@property (nonatomic ,strong)UILabel * lab1 ;
@property (nonatomic ,strong)UILabel * lab2 ;
@property (nonatomic ,strong)UILabel * lab3 ;

@property (nonatomic,strong)UIView * alljinDu;
@property (nonatomic,strong)UIView * jinDuTiao;
@end

@implementation MCVIPCenterHeaderView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    self.backgroundColor=[UIColor clearColor];
    
    _backImgV=[[UIImageView alloc]init];
    [self addSubview:_backImgV];
    _backImgV.userInteractionEnabled=YES;
    _backImgV.frame=CGRectMake(0, 0, G_SCREENWIDTH, H_MCVIPCenter);
 

    
    _lab1=[[UILabel alloc]initWithFrame:CGRectMake(30, 65, 150, 25)];
    _lab1.text=@"";
    _lab1.font=[UIFont systemFontOfSize:18];
    _lab1.textColor=[UIColor whiteColor];
    _lab1.textAlignment=NSTextAlignmentLeft;
    [self addSubview:_lab1];
    _lab2=[[UILabel alloc]initWithFrame:CGRectMake(30, 65+25, 150, 15)];
    _lab2.text=@"";
    _lab2.font=[UIFont systemFontOfSize:12];
    _lab2.textColor=RGB(180,184,194);
    _lab2.textAlignment=NSTextAlignmentLeft;
     [self addSubview:_lab2];
    _lab3=[[UILabel alloc]initWithFrame:CGRectMake(30, 65+25+15, 150, 15)];
    _lab3.text=@"";
    _lab3.font=[UIFont systemFontOfSize:12];
    _lab3.textColor=RGB(180,184,194);
    _lab3.textAlignment=NSTextAlignmentLeft;
    [self addSubview:_lab3];
    
    
    UIView * alljinDu =[[UIView alloc]initWithFrame:CGRectMake(30, 65+25+15+15+10, 175, 2)];
    alljinDu.layer.cornerRadius=1;
    alljinDu.clipsToBounds=YES;
    [self addSubview:alljinDu];
    _alljinDu=alljinDu;
    
    UIView * jinDuTiao =[[UIView alloc]init];
    jinDuTiao.layer.cornerRadius=1;
    jinDuTiao.clipsToBounds=YES;
    [alljinDu addSubview:jinDuTiao];
    _jinDuTiao=jinDuTiao;
}


+(CGFloat)computeHeight:(id)info{
//    375:(180+75)
    return H_MCVIPCenter +10;
}


-(void)setDataSource:(MCGetUserVipInfoDataModel *)dataSource{
    _dataSource = dataSource;
    if (!dataSource.HalfMonBetMoney||dataSource.HalfMonBetMoney==nil) {
        return;
    }
    NSString * VsID = [NSString stringWithFormat:@"%@",dataSource.VsID];
    NSInteger t_VsID =[VsID integerValue];
    NSString *HalfMonBetMoney = GetRealSNum(dataSource.HalfMonBetMoney);
    NSString * str1 = [NSString stringWithFormat:@"当前消费   %@",HalfMonBetMoney];
    NSRange range1 = [str1 rangeOfString:[NSString stringWithFormat:@"%@",HalfMonBetMoney]];
    NSMutableAttributedString *attri1 = [[NSMutableAttributedString alloc] initWithString:str1];
    [attri1 addAttribute:NSForegroundColorAttributeName value:RGB(234,240,253) range:NSMakeRange(range1.location, range1.length)];
    _lab2.attributedText=attri1;

    
    
    if (t_VsID>5) {
        
        [_jinDuTiao mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_alljinDu.mas_left).offset(0);
            make.width.mas_equalTo(175);
            make.top.bottom.equalTo(_alljinDu);
        }];
        _lab3.text=@"当前为最高等级VIP";
    }else{
        
        CGFloat W = [dataSource.HalfMonBetMoney doubleValue]/([dataSource.HalfMonBetMoney doubleValue] +[dataSource.UpDiffMoney doubleValue]) * 175.0;
        
//        W = 80;
        [_jinDuTiao mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_alljinDu.mas_left).offset(0);
            make.width.mas_equalTo(W);
            make.top.bottom.equalTo(_alljinDu);
        }];
        NSString * UpDiffMoney=GetRealSNum(dataSource.UpDiffMoney);
        NSString * str2 = [NSString stringWithFormat:@"晋级还需   %@",UpDiffMoney];
        NSRange range2 = [str2 rangeOfString:[NSString stringWithFormat:@"%@",UpDiffMoney]];
        NSMutableAttributedString *attri2 = [[NSMutableAttributedString alloc] initWithString:str2];
        [attri2 addAttribute:NSForegroundColorAttributeName value:RGB(234,240,253) range:NSMakeRange(range2.location, range2.length)];
        _lab3.attributedText=attri2;
    }
    
    
    
    if (t_VsID==0) {
        _backImgV.image=[UIImage imageNamed:@"VIP_0_wudengji"];
        _lab1.text = @"您还不是VIP";
        _alljinDu.backgroundColor=RGB(80,85,92);
        _jinDuTiao.backgroundColor=RGB(132,141,154);
    }else if (t_VsID==1){
        _backImgV.image=[UIImage imageNamed:@"VIP_1_qingtong"];
        _lab1.text = @"青铜VIP";
        _alljinDu.backgroundColor=RGB(88,55,22);
        _jinDuTiao.backgroundColor=RGB(181,136,91);
    }else if (t_VsID==2){
        _backImgV.image=[UIImage imageNamed:@"VIP_2_baiyin"];
        _lab1.text = @"白银VIP";
        _alljinDu.backgroundColor=RGB(27,46,63);
        _jinDuTiao.backgroundColor=RGB(79,110,137);
    }else if (t_VsID==3){
        _backImgV.image=[UIImage imageNamed:@"VIP_3_huangjin"];
        _lab1.text = @"黄金VIP";
        _alljinDu.backgroundColor=RGB(106,81,47);
        _jinDuTiao.backgroundColor=RGB(198,161,110);
    }else if (t_VsID==4){
        _backImgV.image=[UIImage imageNamed:@"VIP_4_bojin"];
        _lab1.text = @"铂金VIP";
        _alljinDu.backgroundColor=RGB(44,37,57);
        _jinDuTiao.backgroundColor=RGB(119,104,150);
    }else if (t_VsID==5){
        _backImgV.image=[UIImage imageNamed:@"VIP_5_zuanshi"];
        _lab1.text = @"钻石VIP";
        _alljinDu.backgroundColor=RGB(84,50,94);
        _jinDuTiao.backgroundColor=RGB(162,110,176);
    }else if (t_VsID==6){
        _backImgV.image=[UIImage imageNamed:@"VIP_6_wangzhe"];
        _lab1.text = @"王者VIP";
        _alljinDu.backgroundColor=RGB(89,30,28);
        _jinDuTiao.backgroundColor=RGB(187,85,77);
    }
    
    
    
}


@end













































